home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / utilitys / 81 / spiro.lst < prev    next >
Encoding:
File List  |  1987-09-03  |  6.3 KB  |  423 lines

  1. ' ST Applications Dec.1986 pag 10
  2. Titlew 2,"ST APPLICATIONS SPIROGRAPH"
  3. Fullw 2
  4. Clearw 2
  5. Color 1
  6. Dim Red(15),Blue(15),Green(15)
  7. Rinc=0.5
  8. Size:
  9. Sizex=0
  10. Sizey=0
  11. Angle=1
  12. Swcolor$="normal"
  13. If Xbios(4)=2 Then
  14.   Res=2
  15. Else
  16.   Res=1
  17. Endif
  18. Gosub Switch_background_color
  19. Swcolor$="revers"
  20. Type$="1"
  21. M$="There are five|types of spirographs.|Hit the mouse button|after picture is finished"
  22. Alert 3,M$,1,"OK|Quit",C
  23. If C=2 Then
  24.   Gosub Restore_color
  25.   End
  26. Else
  27.   M$="Enter the type of|spirograph you want"
  28.   Alert 2,M$,0,"Spiro|Sine|Pies",C
  29. Endif
  30. If C=1 Then
  31.   M$="Enter the type of Spiro"
  32.   Alert 2,M$,0,"#1|#2|#3",C
  33.   Type=C
  34. Else
  35.   Type=C+2
  36. Endif
  37. Gosub Get_angle
  38. M$="What color background|color do you want"
  39. Alert 2,M$,0,"White|Black",C
  40. If C=1 Then
  41.   Bkg=7
  42. Else
  43.   Bkg=0
  44. Endif
  45. If Res=2 Then
  46.   Gosub Switch_background_color
  47.   Swcolor$="normal"
  48.   Clearw 2
  49.   K=2
  50.   Goto Ang
  51. Endif
  52. M$="Enter color range"
  53. Alert 2,M$,0,"Earth|Rainbow",C
  54. K=4
  55. Clearw 2
  56. Gosub Switch_background_color
  57. Swcolor$="normal"
  58. On C Gosub Col310,Col430
  59. Goto Col550
  60. Procedure Col310
  61.   Red(4)=2
  62.   Blue(4)=7
  63.   Green(4)=7
  64.   Col320:
  65.   Red(5)=0
  66.   Blue(5)=7
  67.   Green(5)=7
  68.   Col330:
  69.   Red(6)=0
  70.   Blue(6)=5
  71.   Green(6)=6
  72.   Red(7)=0
  73.   Blue(7)=3
  74.   Green(7)=6
  75.   Col350:
  76.   Red(8)=0
  77.   Blue(8)=1
  78.   Green(8)=6
  79.   Col360:
  80.   Red(9)=3
  81.   Blue(9)=2
  82.   Green(9)=6
  83.   Col370:
  84.   Red(10)=4
  85.   Blue(10)=1
  86.   Green(10)=6
  87.   Col380:
  88.   Red(11)=5
  89.   Blue(11)=0
  90.   Green(11)=4
  91.   Col390:
  92.   Red(12)=6
  93.   Blue(12)=0
  94.   Green(12)=6
  95.   Col400:
  96.   Red(13)=7
  97.   Blue(13)=0
  98.   Green(13)=5
  99.   Col410:
  100.   Red(14)=7
  101.   Blue(14)=2
  102.   Green(14)=6
  103.   Col420:
  104.   Red(15)=7
  105.   Blue(15)=4
  106.   Green(15)=6
  107. Return
  108. Goto Col550
  109. Procedure Col430
  110.   Red(4)=7
  111.   Blue(4)=5
  112.   Green(4)=0
  113.   Col440:
  114.   Red(5)=7
  115.   Blue(5)=4
  116.   Green(5)=0
  117.   Col450:
  118.   Red(6)=0
  119.   Blue(6)=7
  120.   Green(6)=0
  121.   Col460:
  122.   Red(7)=0
  123.   Blue(7)=7
  124.   Green(7)=5
  125.   Col470:
  126.   Red(8)=0
  127.   Blue(8)=7
  128.   Green(8)=7
  129.   Col480:
  130.   Red(9)=0
  131.   Blue(9)=5
  132.   Green(9)=7
  133.   Col490:
  134.   Red(10)=0
  135.   Blue(10)=2
  136.   Green(10)=7
  137.   Col500:
  138.   Red(11)=0
  139.   Blue(11)=0
  140.   Green(11)=7
  141.   Col510:
  142.   Red(12)=5
  143.   Blue(12)=0
  144.   Green(12)=7
  145.   Col520:
  146.   Red(13)=7
  147.   Blue(13)=0
  148.   Green(13)=7
  149.   Col530:
  150.   Red(14)=7
  151.   Blue(14)=0
  152.   Green(14)=4
  153.   Col540:
  154.   Red(15)=7
  155.   Blue(15)=0
  156.   Green(15)=2
  157. Return
  158. Col550:
  159. For Col=4 To 15
  160.   R=Red(Col)
  161.   B=Blue(Col)
  162.   G=Green(Col)
  163.   Gosub Newcolor
  164. Next Col
  165. Ang:
  166. Deffn A(Angle)=Angle*3.1428/180
  167. R=1
  168. Xo=0
  169. Yo=0
  170. Xoo=0
  171. Yoo=0
  172. K=1
  173. Poke 226560,1
  174. If Type=4 Then
  175.   Gosub Four
  176.   Goto Sou
  177. Endif
  178. If Type=5 Then
  179.   Gosub Five
  180.   Goto Sou
  181. Endif
  182. Startspiro:
  183. If Res=1 Then
  184.   K=K+1
  185.   If K>15 Then
  186.     K=4
  187.   Endif
  188. Else
  189.   K=2
  190. Endif
  191. Color K
  192. Deftext 1,,,
  193. Deffill K,2,8
  194. On Type Gosub One,Two,Three
  195. Angle=Angle+A
  196. If Angle>360 Then
  197.   Angle=Angle-360
  198. Endif
  199. R=R+Rinc
  200. If R>150 Then
  201.   Goto Sou
  202. Endif
  203. Goto Startspiro
  204. Sou:
  205. Sound 1,14,2,3,5
  206. Sound 1,0,0,0,0
  207. Poke 226560,0
  208. B=0
  209. Eloop:
  210. If B>0 Then
  211.   Goto Size
  212. Endif
  213. Gosub Getmouse
  214. Goto Eloop
  215. End
  216. Procedure Newcolor
  217.   R=R*142
  218.   G=G*142
  219.   B=B*142
  220.   Setcolor Col,R,G,B
  221. Return
  222. Procedure Switch_background_color
  223.   If Swcolor$="normal" Then
  224.     Col=1
  225.     R=0
  226.     G=0
  227.     B=7
  228.     Gosub Newcolor
  229.     Col=3
  230.     R=0
  231.     G=0
  232.     B=7
  233.     Gosub Newcolor
  234.     Col=2
  235.     R=0
  236.     G=3
  237.     B=7
  238.     Gosub Newcolor
  239.     Col=0
  240.     R=7
  241.     G=7
  242.     B=7
  243.     Gosub Newcolor
  244.   Else
  245.     Col=1
  246.     R=7
  247.     G=7
  248.     B=7
  249.     Gosub Newcolor
  250.     Col=3
  251.     R=7
  252.     G=7
  253.     B=7
  254.     Gosub Newcolor
  255.     Col=0
  256.     R=Bkg
  257.     G=Bkg
  258.     B=Bkg
  259.     Gosub Newcolor
  260.   Endif
  261. Return
  262. Procedure One
  263.   X=R*Sin(Fn A(Angle))+Xo
  264.   X0=R*Sin(Fn A(Angle))
  265.   Y=R*Cos(Fn A(Angle))+Yo
  266.   Yo=R*Cos(Fn A(Angle))
  267.   Line Res*(152),85,Res*(Xo+152),Yo+85
  268.   Line Res*(152+Xo),85+Yo,Res*(X+152),Y+85
  269.   Line Res*(152+X),85+Y,Res*(152),85
  270. Return
  271. Procedure Two
  272.   X=R*Sin(Fn A(Angle))+Xo
  273.   Xo=R*Sin(Fn A(Angle))
  274.   Y=R*Cos(Fn A(Angle))+Yo
  275.   Yo=R*Cos(Fn A(Angle))
  276.   Line Res*(152+Xo),85+Yo,Res*(X+152),Y+85
  277. Return
  278. Procedure Three
  279.   Xn=(R*Sin(Fn A(Angle)))
  280.   Yn=(R*Cos(Fn A(Angle)))
  281.   Line Res*(152+Xoo),(85+Yoo),Res*(Xn+152),(Yn+85)
  282.   Xoo=(R*Sin(Fn A(Angle))+Xn)
  283.   Yoo=(R*Cos(Fn A(Angle))+Yn)
  284. Return
  285. Procedure Four
  286.   Xres=609
  287.   Yres=186
  288.   Size=4
  289.   C=2
  290.   If Res=1 Then
  291.     Xres=305
  292.     C=4
  293.     Size=2
  294.   Endif
  295.   Sinamp=(Rnd(9)*200)
  296.   Cosamp=(Rnd(9)*200)
  297.   Sinper=(Rnd(9)*100)
  298.   Cosper=(Rnd(9)*100)
  299.   For Xpoint=0 To Xres Step Size
  300.     If Res=1 Then
  301.       Color C
  302.       C=C+1
  303.       If C=16 Then
  304.         C=4
  305.       Endif
  306.     Else
  307.       Color 2
  308.     Endif
  309.     Siney=(Sin(Xpoint/Sinper)*Sinamp)+(Yres/2)
  310.     Cosey=(Cos(Xpoint/Cosper)*Cosamp)+(Yres/2)
  311.     Line Xpoint,Siney,Xres-Xpoint,Cosey
  312.   Next Xpoint
  313. Return
  314. Procedure Five
  315.   If Res=1 Then
  316.     Maxcol=15
  317.     Mincol=4
  318.   Else
  319.     Maxcol=3
  320.     Mincol=2
  321.   Endif
  322.   K=Mincol
  323.   L=150*Res
  324.   M=85
  325.   D=300*Res
  326.   If A<20 Then
  327.     Innc=300
  328.   Endif
  329.   If A>19 Then
  330.     Innc=6000/A
  331.   Endif
  332.   Eangle=A*10
  333.   Bangle=0
  334.   For Z=1 To Innc
  335.     Color K
  336.     Deffill K,,
  337.     Deftext 1,,,,
  338.     Pcircle L,M,D,Bangle,Eangle
  339.     K=K+1
  340.     If K>Maxcol Then
  341.       K=Mincol
  342.     Endif
  343.     Bangle=Eangle
  344.     Eangle=Bangle+A*10
  345.   Next Z
  346. Return
  347. Procedure Getmouse
  348.   B=Mousek
  349.   Mx=Mousex
  350.   My=Mousey
  351.   If B>0 Then
  352.     Sound 1,9,2,5,5
  353.     Sound 1,0,0,0,0
  354.   Endif
  355. Return
  356. Procedure Get_angle
  357.   Clearw 2
  358.   Line 10,80,250,80
  359.   Line 70,80,70,85
  360.   Line 130,80,130,85
  361.   Line 10,80,10,85
  362.   Line 190,80,190,85
  363.   Line 250,80,250,85
  364.   Text 0,10," 0      90     180    270     360"
  365.   Restart:
  366.   Gosub Getmouse
  367.   If Mx<10 Then
  368.     Mx=10
  369.     If Mx>250 Then
  370.       Mx=250
  371.     Endif
  372.   Endif
  373.   Print At(9,12);"angel =",Int((Mx-10)*3/2),"  "
  374.   Deftext 0,,,
  375.   Deffill 0,,
  376.   Color 0
  377.   Line Omx,60,Omx,79
  378.   Line Omx,79,Omx+3,76
  379.   Line Omx,79,Omx-3,76
  380.   Deftext 2,,,
  381.   Deffill 2,,
  382.   Color 2
  383.   Line Mx,79,Mx+3,76
  384.   Line Mx,79,Mx-3,76
  385.   Line Mx,60,Mx,79
  386.   Omx=Mx
  387.   Deftext 1,,,
  388.   Deffill 1,,
  389.   Color 1
  390.   If B=0 Then
  391.     Goto Restart
  392.   Endif
  393.   A=Int((Mx-10)*3/2)
  394. Return
  395. Procedure Restore_color
  396.   Col=1
  397.   R=0
  398.   G=0
  399.   B=0
  400.   Gosub Re_color
  401.   Col=3
  402.   R=0
  403.   G=0
  404.   B=0
  405.   Gosub Re_color
  406.   Col=2
  407.   R=0
  408.   G=0
  409.   B=7
  410.   Gosub Re_color
  411.   Col=0
  412.   R=7
  413.   G=7
  414.   B=7
  415.   Gosub Re_color
  416. Return
  417. Procedure Re_color
  418.   R=R*1
  419.   G=G*1
  420.   B=B*1
  421.   Setcolor Col,R,G,B
  422. Return
  423.